package com.example.mydesignmodule.zerenlian;

/**
 * @author tgw
 * @date 2021/3/1
 * @describe
 */
abstract class DutyChainHandle {

    private DutyChainHandle dutyChainHandle;
    private int mLevel;

    public DutyChainHandle getDutyChainHandle() {
        return dutyChainHandle;
    }

    public void setDutyChainHandle(DutyChainHandle dutyChainHandle) {
        this.dutyChainHandle = dutyChainHandle;
    }

    public int getmLevel() {
        return mLevel;
    }

    public void setmLevel(int mLevel) {
        this.mLevel = mLevel;
    }

    public void handleRequest(int level) {
        if (level <= getmLevel()){
            handle(this);
            System.out.println("目标拦截器 处理");
        }else {
            if (getDutyChainHandle() != null){
                getDutyChainHandle().handleRequest(level);
            }else {
                System.out.println("任何拦截器都处理不了处理");
            }
        }
    }

    public abstract void handle(DutyChainHandle handle);
}
